package org.syyo.admin.common.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.syyo.admin.domain.ResultVo;

/**
 * 统一捕获自定义异常类
 */
@ControllerAdvice//控制器增强
public class ExceptionCatch {


    @ExceptionHandler(SysException.class)
    @ResponseBody
    public ResultVo customException(SysException sysException){
        ResultVo<Object> resultVo = new ResultVo<>();
        resultVo.setCode(sysException.getCode());
        resultVo.setMessage(sysException.getMessage());
        return resultVo;
    }

}
